<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<ul class="breadcrumb">
			<li class="active">
				<i class="icon-home home-icon"></i>
				<a href="#">系统首页</a>
			</li>
			<li class="active">
				用户管理
			</li>
			<li class="active">
				订单记录
			</li>
		</ul><!-- .breadcrumb -->
	</div>

	<div class="page-content">
		<div class="row">
			<div class="page-header">
				<h1>订单记录</h1>
			</div>
        	<div class="col-xs-12 margin_t margin_b">
				<div class="table-responsive  tab">
					<table id="sample-table-1" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th class="center" style="width: 3%;">
									<label>
										<input type="checkbox" class="ace" />
										<span class="lbl"></span>
									</label>
								</th>
								<th>订单编号</th>
                                <th>手机号码</th>
                                <th>设备大类</th>
                                <th>设备规格</th>
                                <th>订单状态</th>
                                <th>支付方式</th>
                                <th>支付状态</th>
                                <th>订单总额</th>
                                <th>订单类型</th>
                                <th>联系人姓名</th>
                                <th>联系人电话</th>
                                <th>下单时间</th>
                                <th>操作</th>
							</tr>
						</thead>

						<tbody>
							<?php if (isset($result)&&count($result)>0){
                            	foreach ($result as $app){
                            	?>
							<tr>
								<td class="center">
                                	<p>
									<label>
										<input type="checkbox" class="ace" name="num[]" value="<?php echo $app->id;?>"/>
										<span class="lbl"></span>
									</label>
                                    </p>
								</td>
								<td><p><?php echo $app->order_no;?></p></td>
                                <td><p><?php echo $app->user_phone;?></p></td>
                                <td><p><?php echo $app->category_name;?></p></td>
                                <td><p><?php echo $app->type_name;?></p></td>
                                <td><p><?php 
                                	if($app->status == 0){
                                		echo "未完成";
                                	}elseif($app->status == 1){
                                		echo "抢单中";
                                	}elseif($app->status == 2){
                                		echo "等待客户确认";
                                	}elseif($app->status == 3){
                                		echo "确认使用";
                                	}elseif($app->status == 4){
                                		echo "致电客户";
                                	}elseif($app->status == 5){
                                		echo "确认开始";
                                	}elseif($app->status == 6){
                                		echo "确认结束";
                                	}elseif($app->status == 7){
                                		echo "订单取消";
                                	}elseif($app->status == 8){
                                		echo "投诉中";
                                	}
                                	?></p></td>
                                <td><p><?php echo $app->payment;?></p></td>
                                <td><p><?php 
                                	if($app->payment_status == 0){
                                		echo "未支付";
                                	}elseif($app->payment_status == 1){
                                		echo "已支付";
                                	}
                                	?></p></td>
                            	<td><p><?php echo $app->order_price.'+'.$app->order_tip;?></p></td>
                            	<td><p><?php 
                                	if($app->order_type == 1){
                                		echo "即时";
                                	}elseif($app->order_type == 2){
                                		echo "预约";
                                	}
                                	?></p></td>
                            	<td><p><?php echo $app->contact_name;?></p></td>
                            	<td><p><?php echo $app->contact_phone;?></p></td>
                                <td><p><?php echo $app->create_time;?></p></td>
                                <td><p>
									    <a class="btn btn-sm btn-info" href="<?php echo base_url().'admin/order/look/'.$app->id;?>"><i class="icon-edit"></i>详细</a>
                                    </p>
                                </td>
    						</tr>
    						<?php }
                            }else{?>
                            <tr>
                            	<td colspan="15">无数据</td>
                            </tr>
                            <?php }?>
						</tbody>
					</table>
				</div><!-- /.table-responsive -->
			</div>
        
        	<div class="col-sm-12">
            	<div class="modal-footer no-margin-top">
                	<div class="pull-left record">
						共<?php echo $count;?>条记录
                    </div>
            		<?php if (isset($page))echo $page;?>
            	</div>
            </div>
		</div><!-- /.row -->
	</div><!-- /.page-content -->
</div><!-- /.main-content -->
<div id="delsomeModal" class="modal fade" role="dialog" aria-hidden="true">
	<div class="modal-dialog" style="width: 300px">
		<div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h3>提示信息</h3>
			</div>
			<div class="modal-body">
			  <p>删除后将无法恢复，确定要删除所选订单吗？</p>
			</div>
			<div class="modal-footer">
			  <button id="delsomebtn" type="button" class="btn btn-danger">确定</button>
			  <a href="#" class="btn btn-info" data-dismiss="modal" aria-hidden="true">取消</a>
			</div>
		</div>
	</div>
</div>
<div id="cancelModal" class="modal fade" role="dialog" aria-hidden="true">
	<div class="modal-dialog" style="width: 300px">
		<div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h3>提示信息</h3>
			</div>
			<div class="modal-body">
			  <p>取消订单后将无法恢复，已支付的金额会直接退回用户支付账户<br>确定要取消所选订单吗？</p>
			</div>
			<div class="modal-footer">
			  <input type="hidden" id="cancel_order_id" value="">
			  <a id="cancelbtn" href="#" onclick="cancel()" class="btn btn-danger">确定</a>
			  <a href="#" class="btn btn-info" data-dismiss="modal" aria-hidden="true">取消</a>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
function delSomeModal(){
	if(checkSelect()){
    	$('#delsomeModal').modal('show');
	}else{
		alert('请选择正确的记录进行删除');
	}
}
$("#delsomebtn").click(function(){
	$("#delForm").submit();
});
function cancelmodal(id){
	$("#cancel_order_id").val(id);
    $('#cancelModal').modal('show');
}
function cancel(){
	$('#cancelModal').modal('hide');
	showLoading('取消中...');
	$.ajax( {
        url:'<?php echo site_url("admin/order/cancel")?>',
        data:{order_id:$('#cancel_order_id').val()},
        type:'post',
        cache:false,
        dataType:'json',    
        success:function(result) {
        	hideLoading();
        	if(result.ret == '200'){
            	if(result.data.code == '0'){
            		window.location.reload();
            	}else{
            		alert("取消失败:"+result.data.msg);
            	}
        		
			}else {
				alert("取消失败:"+result.msg);
			}
        },
        error : function() {       
			alert("error");
        }
	});
}
</script>
	